<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>综合练习</title>
</head>
<body>
<div>
    <div v-if="!isLogin">
        <a href="www.baidu.com">注册</a>
        <a href="javascript:void (0)"@click="isLogin=true">登陆</a>
    </div>
    <div v-else>
        <input type="text" v-model="name">
        <input type="button" value="add" @click="addName()">
    </div>
    <ul>
        <li v-for="name in arr">{{name}}</li>
    </ul>
</div>
<script src="../js/vue.js"></script>
<script>
    let v=new Vue({
        el:"body>div",
        data:{
            isLogin:false,
            name:"",
            arr:["刘备","关羽","张飞","赵云"],
        },
        methods:{
            addName(){
                if (v.name==""){
                    return;
                }
                v.arr.push(v.name);
                //v.name="";
            }
        }
    })
</script>
</body>
</html>